package com.boyunv.chainduty.example03;
/*
 *@description
 *
 *@author boyunv
 *@create 2023/8/26 14:38
 *@version 1.0
 */

import com.alibaba.fastjson.JSON;
import com.boyunv.chainduty.example02.AuthService;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Client {
    private Logger logger=LoggerFactory.getLogger(Client.class);
    
    @Test
    public  void tst_auth() throws ParseException {
        //定义责任链
        AuthLink authLink = new Level3AuthLink("100013", "笑凡")
                .appendNext(new Level2AuthLink("100012", "jdii")
                        .appendNext(new Level1AuthLink("100011", "ddd"))
                );
        SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date parse = s.parse("2023-8-26 14:47:35");
        logger.info("测试结果:{}", JSON.toJSONString(authLink.doAuth("硕士","51655",parse)));
        
        //模拟三级负责人审批
        AuthService.auth("100013","10252125415");
        logger.info("测试结果:{}","模拟三级负责人审批,几句话");
        logger.info("测试结果:{}",JSON.toJSONString(authLink.doAuth("dddd","8615651",parse)));
    }
}
